package com.applet.applet_shangcheng.dao;

import com.applet.applet_shangcheng.entity.CashDiscount;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CashDiscountMapper {
    @Insert({
            "insert into tb_cash_discount (t_code,integral,money,balance,create_time,employ_time,status,user_id) values (#{tCode},#{integral},#{money},#{balance},#{createTime},#{employTime},#{status},#{userId})"
            //"insert into tb_cash_discount ()"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertCashDiscount(CashDiscount cashDiscount);

    @Update({
            //"update tb_cash_discount set code=#{code},integral=#{integral},money=#{money},balance=#{balance},create_time=#{createTime},employ_time=#{employTime},status=#{status} where user_id=#{userId}"
            "update tb_cash_discount set integral=#{integral},money=#{money},balance=#{balance},create_time=#{createTime},employ_time=#{employTime},status=#{status},user_id=#{userId} where t_code=#{tCode}"
    })
    int updateCashDiscount(CashDiscount cashDiscount);

    @Select({
            "select id,t_code,integral,money,balance,create_time,employ_time,status,user_id from tb_cash_discount where user_id=#{userId}"
    })
    List<CashDiscount> selectCashDiscountByUserId(@Param("userId") String userId);
    @Select({
            "select id,t_code,integral,money,balance,create_time,employ_time,status,user_id from tb_cash_discount where t_code=#{code}"
    })
    CashDiscount selectCashDiscountByCode(@Param("code")String code);
    @Select({
            "select id,t_code,integral,money,balance,create_time,employ_time,status,user_id from tb_cash_discount"
    })
    List<CashDiscount> findAll();


    Page<CashDiscount> findAll1(String queryString);
    @Select({
            "select id,t_code,integral,money,balance,create_time,employ_time,status,user_id from tb_cash_discount where id=#{id}"
    })
    CashDiscount findById(int id);

    @Delete({
            "delete from tb_cash_discount where t_code = #{code}"
    })
    int deleteCashDiscountByCode(@Param("code") String code);
}

